import tnx from '@/tnx.js';

export default function (vm, auto = true) {
    tnx.util.dialog.open({
        properties: ['openFile'],
        title: '选择根工程的pom.xml文件',
        filters: [{
            name: 'pom.xml',
            extensions: ['xml'],
        }],
    }).then(filePaths => {
        let filePath = filePaths[0];
        if (filePath) {
            let filename = tnx.util.file.getFileName(filePath);
            if (filename !== 'pom.xml') {
                tnx.error('请选择 pom.xml 文件');
                return;
            }
            vm.$router.push(
                '/maven?auto=' + auto + '&path=' + encodeURIComponent(filePath) + '&t=' + new Date().getTime());
        }
    });
}
